package com.lzx.adx.report.controller.v1.ks;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.lzs.adx.commmon.utils.Result;
import com.lzx.adx.report.bean.mapper.ReportMapper;
import com.lzx.adx.report.dto.OrderRecodDTO;
import com.lzx.adx.report.dto.ReportDTO;
import com.lzx.adx.report.model.ks.request.KsReportRequest;
import com.lzx.adx.report.service.AccountService;
import com.lzx.adx.report.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RequestMapping("/dsp/elmunion")
@RestController
@Slf4j
public class KsElmUnionReportController {

    @Resource
    private ReportService reportService;

    @Autowired
    private ReportMapper reportMapper;

    @Autowired
    private ThreadPoolTaskExecutor reportExecutor;

    @Autowired
    private AccountService accountService;




    @GetMapping("/report")
    public ResponseEntity v1Reqport(KsReportRequest ksReportRequest, HttpServletRequest request){
        //广点通，转换
        ReportDTO reportDTO=reportMapper.toReportKsReportDTO(ksReportRequest);
        reportDTO.setBizRequestId(IdUtil.fastUUID());
        reportDTO.setCreateTime(new Date());
        reportDTO.setUpdateTime(new Date());
        reportDTO.setExtend(JSON.toJSONString(ksReportRequest));
        reportExecutor.execute(()->{
            reportService.saveData(reportDTO);
        });

        return ResponseEntity.ok(new Result());
    }
















}
